#
#        Python GUI - Fonts - Swing
#

from GFonts import Font as GFont
import java.awt as awt
from JHacks import *

class Font(GFont):
    def __init__(self,family,size=12,style=[], _j_font=None):
        if _j_font:
            self._j_font=_j_font
            GFont.__init__(self)
            return
        traits=0
        if 'bold' in style:
            traits |= awt.Font.BOLD
        if 'italic' in style:
            traits |= awt.Font.ITALIC
        self._j_font=awt.Font(family,traits,int(size))
        GFont.__init__(self)
    
    def get_family(self):
        return self._j_font.getFamily()
    
    def get_size(self):
        return self._j_font.getSize()
    
    def get_style(self):
        style=[]
        traits=self._j_font.getStyle()
        if traits & awt.Font.BOLD: style.append('bold')
        if traits & awt.Font.ITALIC: style.append('italic')
        return style

def _from_j_font(_j_font):
    return Font(None,_j_font=_j_font)